<!--php文件夹下1~29张png图为基础内容-->

<?php 
	echo "<br>";
	function addsum() {
		static $x = 0;
		echo $x."<br>";
		$x++;
	}
	addsum();
	addsum();
	addsum();
?>


<?php
	echo "<br>"; 
	echo "string";
	print "<br>";
	echo "1";
	print "<br>";
	print "22dashdiuah22";
	print "<br>";
	print "33";
	print "<br>";
	$var = print "4";
	print "<br>";
	echo $var;
?>

<?php
$txt1="Learn PHP";
$txt2="W3School.com.cn";
$cars=array("Volvo","BMW","SAAB");
echo $txt1;
echo "<br>";
echo "Study PHP at $txt2";
echo "<br>";
echo "My car is a {$cars[0]}";
?>

<?php 
$x = 5985;
var_dump($x);
$x = -345; // 负数 
var_dump($x);
$x = 0x8C; // 十六进制数
var_dump($x);
$x = 047; // 八进制数
var_dump($x);
?>

<?php 
$cars=array("Volvo","BMW","SAAB");
echo count($cars);
var_dump($cars);
?>


<?php
$x = array("a" => "red", "b" => "green"); 
$y = array("c" => "blue", "d" => "yellow"); 
$z = $x + $y; // $x 与 $y 的联合
echo $z["c"];
// var_dump($z);
echo "<br>";
var_dump($x == $y);
echo "<br>";
var_dump($x === $y);
echo "<br>";
var_dump($x != $y);
echo "<br>";
var_dump($x <> $y);
echo "<br>";
var_dump($x !== $y);
?>   


<?php
$t=date("H");

if ($t<"10") {
  echo "Have a good morning!";
} elseif ($t<"20") {
  echo "Have a good day!";
} else {
  echo "Have a good night!";
}
?>

<?php
echo "<br>";
$favcolor="111";

switch ($favcolor) {
   case "111":
     echo "Your favorite color is 111!";
     break;
   case "222":
     echo "Your favorite color is 222!";
     break;
   case "333":
     echo "Your favorite color is 333!";
     break;
   default:
     echo "Your favorite color is null";
}
?>

<?php 
echo "<br>";
$colors = array("red","green","blue","yellow");
/*以字母降序排序*/
rsort($colors); 
$mycolors = array("a"=>"red","b"=>"blue","c"=>"green");
foreach ($colors as $value) {
  echo "$value <br>";
}
foreach ($mycolors as $v=>$value) {
	echo "{$v}=>{$value} <br>";
}
?>

<?php 
echo "<br>";
function echoHello(){
	echo "hello world";
}
echohello();
 ?>


<?php
function familyName($fname) {
  echo "$fname Zhang.<br>";
}

familyName("Li");
familyName("Hong");
familyName("Tao");
familyName("Xiao Mei");
familyName("Jian");
?>


<?php 
echo "<br>";
echo $_SERVER['PHP_SELF'];
//相对地址
echo "<br>";
echo $_SERVER['SERVER_NAME'];
//服务名
echo "<br>";
echo $_SERVER['HTTP_HOST'];
//服务名加端口号
echo "<br>";
//echo $_SERVER['HTTP_REFERER'];
//echo "<br>";
echo $_SERVER['HTTP_USER_AGENT'];
//报头信息
echo "<br>";
echo $_SERVER['SCRIPT_NAME'];
//脚本位置
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name: <input type="text" name="fname">
<input type="submit">
</form>

<?php 
$name = $_REQUEST['fname']; 
echo $name."<br>"; 
?>

<?php 
$name = $_POST['fname']; 
echo $name."<br>"; 
?>






























